package com.zhan.rkforum.config;

import com.zhan.rkforum.controller.interceptor.DataInterceptor;
import com.zhan.rkforum.controller.interceptor.LoginTicketInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author wujiazhan
 * @className WebMvcConfig
 * @description TODO
 * @date 2021-06-21 15:10
 */
@Configuration
@Component
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginTicketInterceptor loginTicketInterceptor;

//    @Autowired
//    private LoginRequriedInterceptor loginRequriedInterceptor;

    @Autowired
    private DataInterceptor dataInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(this.loginTicketInterceptor)
                .excludePathPatterns("/**/*.js","/**/*.css","/**/*.png","/**/*.jpg","/**/*.jpeg")
                .addPathPatterns("/**");
//        registry.addInterceptor(this.loginRequriedInterceptor)
//                .excludePathPatterns("/**/*.js","/**/*.css","/**/*.png","/**/*.jpg","/**/*.jpeg")
//                .addPathPatterns("/**");

        registry.addInterceptor(this.dataInterceptor)
                .excludePathPatterns("/**/*.js","/**/*.css","/**/*.png","/**/*.jpg","/**/*.jpeg")
                .addPathPatterns("/**");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
